from django.db import models
# tests调试用例
# import os,django
# os.environ.setdefault('DJANGO_SETTINGS_MODULE','ccd_zichan.settings')
# django.setup()

# 资产状态
class ComputerStatus(models.Model):
    id = models.AutoField(primary_key=True)
    name = models.CharField(verbose_name="登录用户", max_length=100)      # 用户名
    name_yu = models.CharField('域',max_length=100)                       # 计算机域
    computer_name = models.CharField('计算机名',max_length=100)            # 计算机名
    system_type = models.CharField('系统类型',max_length=100)              # 系统类型
    c_cpu = models.CharField("CPU",max_length=100)                         # CPU型号
    c_memory = models.CharField("内存",max_length=100)                     # 内存
    c_network = models.CharField("IP地址",max_length=100)                  # 网卡IP地址
    mac_network = models.CharField("MAC地址",max_length=100)               # 网卡MAC地址
    c_display = models.CharField("显卡",max_length=100)                    # 显卡
    c_date = models.CharField("硬盘",max_length=100)                      # 硬盘
    c_time = models.DateTimeField("更新时间", auto_now_add=True)           # 更新时间记录
    it_number = models.CharField("资产编号", max_length=100, blank=True)   # IT资产编号
    seat_number = models.CharField("座位编号", max_length=100, blank=True)  # 座位编号
    asset_users = models.CharField("资产使用者", max_length=100, blank=True)  # 资产使用者

    class Meta:
        verbose_name = "资产状态"
        verbose_name_plural = "资产状态"

    def __str__(self):
        return self.it_number


# 储存历史记录
class Computer(models.Model):
    id = models.AutoField(primary_key=True)
    name = models.CharField(verbose_name="登录用户", max_length=100)  # 用户名
    name_yu = models.CharField('域', max_length=100)  # 计算机域
    computer_name = models.CharField('计算机名', max_length=100)  # 计算机名
    system_type = models.CharField('系统类型', max_length=100)  # 系统类型
    c_cpu = models.CharField("CPU", max_length=100)  # CPU型号
    c_memory = models.CharField("内存", max_length=100)  # 内存
    c_network = models.CharField("IP地址", max_length=100)  # 网卡IP地址
    mac_network = models.CharField("MAC地址", max_length=100)  # 网卡MAC地址
    c_display = models.CharField("显卡", max_length=100)  # 显卡
    c_date = models.CharField("硬盘", max_length=100)  # 硬盘
    c_time = models.DateTimeField("更新时间", auto_now_add=True)  # 更新时间记录
    it_number = models.CharField("资产编号", max_length=100, blank=True)  # IT资产编号
    seat_number = models.CharField("座位编号", max_length=100, blank=True)  # 座位编号
    asset_users = models.CharField("资产使用者", max_length=100, blank=True)  # 资产使用者

    class Meta:
        verbose_name = "电子类资产"
        verbose_name_plural = "电子类资产"

    def __str__(self):
        return self.it_number


# 资产报废
class Scrap(models.Model):
    id = models.AutoField(primary_key=True)
    number = models.CharField("资产编号",max_length=100,blank=True)
    category = models.CharField("资产类别",max_length=255,blank=True)
    time = models.DateField("报废时间",auto_now_add=True)


    class Meta:
        verbose_name = "资产报废"
        verbose_name_plural = "资产报废"

    def __str__(self):
        return self.number


# 电子类产品，有IP和MAC地址，做自动化在线
# 1.资产编号
# 2.资产名称（类别+型号）
# 3.类别
# 4.数量
# 5.具体位置
# 6.使用者
# 7.备注
class IpAssets(models.Model):
    id = models.AutoField(primary_key=True)
    ip_number = models.CharField(verbose_name="其他资产编号",max_length=100)
    ip_name = models.CharField(verbose_name="资产名称", max_length=100)
    ip_category = models.CharField(verbose_name="类别", max_length=100)
    ip_num = models.CharField(verbose_name="数量", max_length=100)
    ip_seat_number = models.CharField(verbose_name="具体位置", max_length=100)
    ip_asset_users = models.CharField(verbose_name="资产使用者", max_length=100)
    ip_time = models.DateTimeField(verbose_name="更新时间", auto_now_add=True)
    ip_mac = models.CharField(verbose_name="MAC地址", max_length=100)
    ip_remarks = models.CharField(verbose_name="备注", max_length=100)


# 其他非电子类产品资产
class OAssets(models.Model):
    id = models.AutoField(primary_key=True)
    o_number = models.CharField(verbose_name="其他资产编号",max_length=100)
    o_name = models.CharField(verbose_name="资产名称", max_length=100)
    o_category = models.CharField(verbose_name="类别", max_length=100)
    o_num = models.CharField(verbose_name="数量", max_length=100)
    o_seat_number = models.CharField(verbose_name="具体位置", max_length=100)
    o_asset_users = models.CharField(verbose_name="资产使用者", max_length=100)
    o_time = models.DateTimeField(verbose_name="更新时间", auto_now_add=True)
    o_remarks = models.CharField(verbose_name="备注", max_length=100)
    o_asset_users = models.CharField(verbose_name="资产使用者", max_length=100)

    class Meta:
        verbose_name = "其他非电子类资产"
        verbose_name_plural = "其他非电子类资产"

    def __str__(self):
        return self.o_number


# 保存判断列表数据的表
class NumberTable(models.Model):
    id = models.AutoField(primary_key=True)
    tab_name = models.CharField(verbose_name="数据表名称", max_length=100, blank=True)


# 虚拟资产
class VAssets(models.Model):
    id = models.AutoField(primary_key=True)
    v_ip = models.CharField(verbose_name="IP地址",max_length=255)
    v_mac = models.CharField(verbose_name="MAC地址",max_length=255)
    v_Name = models.CharField(verbose_name="主机名",max_length=255)
    v_cpu = models.CharField(verbose_name="CPU",max_length=255)
    v_memory = models.CharField(verbose_name="内存",max_length=255)
    v_hardDisk = models.CharField(verbose_name="硬盘",max_length=255)
    v_hostName = models.CharField(verbose_name="宿主服务器",max_length=255)
    v_system = models.CharField(verbose_name="操作系统",max_length=255)
    v_remarks = models.CharField(verbose_name="备注",max_length=255)


    class Meta:
        verbose_name = "虚拟资产"
        verbose_name_plural = "虚拟资产"

    def __str__(self):
        return self.v_ip

# makemigrations
#     migrate
